<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/layouts/taglib.jsp"%>

<script src="${ctx}/static/commonjs/crud.js"></script>

<script>
        $(function(){
           $(".saveButton").click(function(){

               var bootstrapValidator = form.data('bootstrapValidator');
               //手动触发验证
               bootstrapValidator.validate();
               if(bootstrapValidator.isValid()){
                   //表单提交的方法、比如ajax提交
               }
           }) ;
        });
         $("form").bootstrapValidator({
            message: "This value is not valid",

            feedbackIcons: {    // 输入框不同状态，显示图片的样式*
                valid: "glyphicon glyphicon-ok",
                invalid: "glyphicon glyphicon-remove",
                validating: "glyphicon glyphicon-refresh"
            },

            fields: {   // 验证

                name: {
                    message: "校区名称验证失败",
                    validators: {
                        notEmpty: {
                            message: "校区名称不能为空"
                        },

                        regexp: {
                            regexp: /([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_]){1,10}$/,
                            message: "校区名称只能包含汉字,英文大小写、数字和下划线"
                        }
                    }
                },
                note:{
                    message:"备注校验失败",
                    validators: {
                        notEmpty: {
                            message: "校区名称不能为空"
                        }
                    },
                }
            }
        });
</script>

 <form action="/enrollandpay/campus/save" class="form-horizontal" id="campusForm">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">报名管理</h4>
    </div>

    <div class="modal-body">
        <input type="hidden" name="id" value="${thisSignup.id}">
        <input type="hidden" name="token" value="${token}">

        <div class="form-group">
            <label class="col-sm-2 control-label" for="activityId">活动名称</label>
            <div class="col-sm-10">
                <select class="form-control"  id="activityId" name="activityId">
                    <c:forEach items="${activities}" var="activity">
                        <option value="${activity.id }" ${thisSignup.activityId eq activity.id ? 'selected=selected':''}>${activity.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label" for="note">备注</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" placeholder="请输入备注" name="note" id="note"
                       value="${thisCampus.note}"/>
            </div>
        </div>

    </div>

    <div class="modal-footer">
        <button type="button" class="btn btn-default" id="dismissCampus" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary saveButton" onclick="doSave('signup')"> 保存</button>
    </div>
</form>
